﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace DentScan2.WebApp
{
    public partial class FindCar : Classes.BaseForm
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            this.CheckLogged();

        }

        protected void bFind_Click(object sender, EventArgs e)
        {
            DoSearch();
        }


        private void DoSearch()
        {

            int exp = -1;
            string regNo = null;
            string rama = null;
            switch (rblSearchWhere.SelectedValue)
            {
                case "0":
                    int.TryParse(tbSS.Text, out exp); break;
                case "1":
                    regNo = tbSS.Text; break;
                case "2":
                    rama = tbSS.Text; break;

            }




            var result = dl.pDamageSearch
                (
                null,
                null,
                exp,
                null,
                null,
                null,
                null,
                regNo,
                null,
                null,
                rama,
                null,
                null,
                null,
                null,
                0,
                int.MaxValue
                ).ToArray();



            if (result.Length == 0)
            {
                rResults.Visible = false;
                lRecordCount.Text = "0";
            }
            else
            {
                int totalCount = Convert.ToInt32(result[0].rn + result[0].rnrev - 1);
                rResults.Visible = true;
                rResults.DataSource = result;
                rResults.DataBind();
                lRecordCount.Text = totalCount.ToString();
            }
        }





    }
}
